extends AnimatedSprite

var life = 4000
const shanghai = 200
var col
onready var Game = get_tree().current_scene.get_node(".")

func _ready():
	pass 

func _process(delta):
	col = $RayCast2D.get_collider()
	if col:
		play("attack")
		pass
	else:
		self.animation = "idle"
	pass
	
func _on_Jinweijianguo_animation_finished():
	if self.animation == "attack":
		col.sub("jinweijianguo",shanghai)
		col.play_hit()
		pass
	pass

func _on_Area2D_input_event(viewport, event, shape_idx):
	if event is InputEventMouseButton and Game.use_shovel:
		if event.is_pressed() and event.button_index == BUTTON_LEFT:
			Game.reset_shovel()
			Game.use_shovel = false
			self.queue_free()
	pass # Replace with function body.
